_gl = window._gl || {};
var _store = (function(window) {
    // Store.js
    var store = {},
        win = (typeof window != 'undefined' ? window : global),
        doc = win.document,
        localStorageName = 'localStorage',
        scriptTag = 'script',
        storage

    store.disabled = false
    store.version = '1.3.20'
    store.set = function(key, value) {}
    store.get = function(key, defaultVal) {}
    store.has = function(key) { return store.get(key) !== undefined }
    store.remove = function(key) {}
    store.clear = function() {}
    store.transact = function(key, defaultVal, transactionFn) {
        if (transactionFn == null) {
            transactionFn = defaultVal
            defaultVal = null
        }
        if (defaultVal == null) {
            defaultVal = {}
        }
        var val = store.get(key, defaultVal)
        transactionFn(val)
        store.set(key, val)
    }
    store.getAll = function() {
        var ret = {}
        store.forEach(function(key, val) {
            ret[key] = val
        })
        return ret
    }
    store.forEach = function() {}
    store.serialize = function(value) {
        return JSON.stringify(value)
    }
    store.deserialize = function(value) {
        if (typeof value != 'string') { return undefined }
        try { return JSON.parse(value) }
        catch(e) { return value || undefined }
    }

    // Functions to encapsulate questionable FireFox 3.6.13 behavior
    // when about.config::dom.storage.enabled === false
    // See https://github.com/marcuswestin/store.js/issues#issue/13
    function isLocalStorageNameSupported() {
        try { return (localStorageName in win && win[localStorageName]) }
        catch(err) { return false }
    }

    if (isLocalStorageNameSupported()) {
        storage = win[localStorageName]
        store.set = function(key, val) {
            if (val === undefined) { return store.remove(key) }
            storage.setItem(key, store.serialize(val))
            return val
        }
        store.get = function(key, defaultVal) {
            var val = store.deserialize(storage.getItem(key))
            return (val === undefined ? defaultVal : val)
        }
        store.remove = function(key) { storage.removeItem(key) }
        store.clear = function() { storage.clear() }
        store.forEach = function(callback) {
            for (var i=0; i<storage.length; i++) {
                var key = storage.key(i)
                callback(key, store.get(key))
            }
        }
    } else if (doc && doc.documentElement.addBehavior) {
        var storageOwner,
            storageContainer
        // Since #userData storage applies only to specific paths, we need to
        // somehow link our data to a specific path.  We choose /favicon.ico
        // as a pretty safe option, since all browsers already make a request to
        // this URL anyway and being a 404 will not hurt us here.  We wrap an
        // iframe pointing to the favicon in an ActiveXObject(htmlfile) object
        // (see: http://msdn.microsoft.com/en-us/library/aa752574(v=VS.85).aspx)
        // since the iframe access rules appear to allow direct access and
        // manipulation of the document element, even for a 404 page.  This
        // document can be used instead of the current document (which would
        // have been limited to the current path) to perform #userData storage.
        try {
            storageContainer = new ActiveXObject('htmlfile')
            storageContainer.open()
            storageContainer.write('<'+scriptTag+'>document.w=window</'+scriptTag+'><iframe src="/favicon.ico"></iframe>')
            storageContainer.close()
            storageOwner = storageContainer.w.frames[0].document
            storage = storageOwner.createElement('div')
        } catch(e) {
            // somehow ActiveXObject instantiation failed (perhaps some special
            // security settings or otherwse), fall back to per-path storage
            storage = doc.createElement('div')
            storageOwner = doc.body
        }
        var withIEStorage = function(storeFunction) {
            return function() {
                var args = Array.prototype.slice.call(arguments, 0)
                args.unshift(storage)
                // See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx
                // and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx
                storageOwner.appendChild(storage)
                storage.addBehavior('#default#userData')
                storage.load(localStorageName)
                var result = storeFunction.apply(store, args)
                storageOwner.removeChild(storage)
                return result
            }
        }

        // In IE7, keys cannot start with a digit or contain certain chars.
        // See https://github.com/marcuswestin/store.js/issues/40
        // See https://github.com/marcuswestin/store.js/issues/83
        var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g")
        var ieKeyFix = function(key) {
            return key.replace(/^d/, '___$&').replace(forbiddenCharsRegex, '___')
        }
        store.set = withIEStorage(function(storage, key, val) {
            key = ieKeyFix(key)
            if (val === undefined) { return store.remove(key) }
            storage.setAttribute(key, store.serialize(val))
            storage.save(localStorageName)
            return val
        })
        store.get = withIEStorage(function(storage, key, defaultVal) {
            key = ieKeyFix(key)
            var val = store.deserialize(storage.getAttribute(key))
            return (val === undefined ? defaultVal : val)
        })
        store.remove = withIEStorage(function(storage, key) {
            key = ieKeyFix(key)
            storage.removeAttribute(key)
            storage.save(localStorageName)
        })
        store.clear = withIEStorage(function(storage) {
            var attributes = storage.XMLDocument.documentElement.attributes
            storage.load(localStorageName)
            for (var i=attributes.length-1; i>=0; i--) {
                storage.removeAttribute(attributes[i].name)
            }
            storage.save(localStorageName)
        })
        store.forEach = withIEStorage(function(storage, callback) {
            var attributes = storage.XMLDocument.documentElement.attributes
            for (var i=0, attr; attr=attributes[i]; ++i) {
                callback(attr.name, store.deserialize(storage.getAttribute(attr.name)))
            }
        })
    }

    try {
        var testKey = '__storejs__'
        store.set(testKey, testKey)
        if (store.get(testKey) != testKey) { store.disabled = true }
        store.remove(testKey)
    } catch(e) {
        store.disabled = true
    }
    store.enabled = !store.disabled

    return store
})(window);

var _helper = (function(store){
    //动态加载css文件
    function loadStyles(url,callback){
        var link = document.createElement("link");
        link.rel = "stylesheet";
        link.type = "text/css";
        link.href = url;
        document.getElementsByTagName("head")[0].appendChild(link);
        link.onload = link.onreadystatechange = function() {
            (!this.readyState || "loaded" == this.readyState || "complete" == this.readyState) && callback && callback()
        }
    }

    //动态加载JS文件
    function loadScript(url,callback){
        var script = document.createElement("script");
        script.charset = "UTF-8";
        script.async = true;
        script.type = "text/javascript";
        script.onerror = function () {
            if(callback && typeof(callback)=="function") callback(true);
        };
        var loaded = false;
        script.onload = script.onreadystatechange = function () {
            if (!loaded && (!script.readyState || "loaded" === script.readyState || "complete" === script.readyState)) {
                loaded = true;
                setTimeout(function () {
                    if(callback && typeof(callback)=="function") callback(true);
                }, 0);
            }
        };
        script.src = url;
        //HTML5中用document.head就好了
        document.getElementsByTagName("head")[0].appendChild(script);
    }
    function loadScriptString(code){
        var script = document.createElement("script");
        script.type = "text/javascript";
        try {
            script.appendChild(document.createTextNode(code));
        } catch (ex){
            script.text = code;
        }
        document.body.appendChild(script);
    }

    //获取文档的宽高 滚动条的宽到 滚动条的位置
    function getDocumentBaseData(){
        var cWidth = 0,cHeight = 0,sWidth = 0,sHeight = 0,sTop = 0,sTeft = 0;
        if (document.compatMode == "BackCompat") {
            cWidth = document.body.clientWidth;
            cHeight = document.body.clientHeight;
            sWidth = document.body.scrollWidth;
            sHeight = document.body.scrollHeight;
            sTop = document.body.scrollTop;
            sTeft = document.body.scrollLeft;
        }
        else { //document.compatMode == "CSS1Compat"
            cWidth = document.documentElement.clientWidth;
            cHeight = document.documentElement.clientHeight;
            sWidth = document.documentElement.scrollWidth;
            sHeight = document.documentElement.scrollHeight;
            sTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollTop;
            sTeft = document.documentElement.scrollLeft == 0 ? document.body.scrollLeft : document.documentElement.scrollLeft;
        }
        return {clientWidth:cWidth,clientHeight:cHeight,scrollWidth:sWidth,scrollHeight:sHeight,scrollTop:sTop,scrollLeft:sTeft};
    }

    //获取当天日期
    function getCurrentDate(sep){
        if(!sep && typeof (sep) != "string") sep="-";
        var d =new Date();
        var y = d.getFullYear();
        var m = parseInt(d.getMonth()) + 1;
        m = m<10?"0"+m:m;
        var dy = d.getDate();
        dy = dy<10?"0"+dy:dy;
        return y+sep+m+sep+dy;
    }

    //计算两个日期之间相差几天
    function getDifferDays(strDateStart,strDateEnd){
        var strDateS = new Date(strDateStart);
        var strDateE = new Date(strDateEnd);
        return parseInt((strDateE-strDateS) / 1000 / 60 / 60 /24)//把相差的毫秒数转换为天数
    }

    //函数节流
    function throttle(method,context){
        clearTimeout(method.tId);
        method.tId=setTimeout(function(){
            method.call(context);
        },500);
    }

    function throttle_delay(method,delay){
        var timer=null;
        return function(){
            var context=this, args=arguments;
            clearTimeout(timer);
            timer=setTimeout(function(){
                method.apply(context,args);
            },delay);
        }
    }

    function throttle_duration(method,delay,duration){
        var timer=null, begin=new Date();
        return function(){
            var context=this, args=arguments, current=new Date();
            clearTimeout(timer);
            if(current-begin>=duration){
                method.apply(context,args);
                begin=current;
            }else{
                timer=setTimeout(function(){
                    method.apply(context,args);
                },delay);
            }
        }
    }

    //关闭当前窗口的方法
    function closeWebPage(){
        if (navigator.userAgent.indexOf("MSIE") > 0) {
            if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
                window.opener = null;
                window.close();
            } else {
                window.open('', '_top');
                window.top.close();
            }
        }
        else if (navigator.userAgent.indexOf("Firefox") > 0||navigator.userAgent.indexOf("Chrome") > 0) {
            window.close();
            window.location.href = 'about:blank ';

        } else {
            window.opener = null;
            window.open('', '_self', '');
            window.close();
        }
    }

    //获取url参数并放到数组中
    function getRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0, i1 = strs.length; i < i1; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    //判断当前浏览器类型
    function getBrowserType(){
        var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
        var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
        var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
        var isEdge = userAgent.indexOf("Windows NT 6.1; Trident/7.0;") > -1 && !isIE; //判断是否IE的Edge浏览器
        var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
        var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
        var isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器

        if (isIE)
        {
            var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
            reIE.test(userAgent);
            var fIEVersion = parseFloat(RegExp["$1"]);
            if(fIEVersion == 7)
            { return "IE7";}
            else if(fIEVersion == 8)
            { return "IE8";}
            else if(fIEVersion == 9)
            { return "IE9";}
            else if(fIEVersion == 10)
            { return "IE10";}
            else if(fIEVersion == 11)
            { return "IE11";}
            else
            { return "0"}//IE版本过低
        }//isIE end
        if (isFF) {  return "FF";}
        if (isOpera) {  return "Opera";}
        if (isSafari) {  return "Safari";}
        if (isChrome) { return "Chrome";}
        if (isEdge) { return "Edge";}
    }
    //判断是否PC端
    function isPC(){
        var userAgentInfo = navigator.userAgent;
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
        }
        return flag;
    }

    function storeWithExpiration(){
        return {
            set: function(key, val, exp){
                store.set(key, { val: val, exp: exp || (24 * 3600 * 1000), time: new Date().getTime(), ver: _gl._version });
            },
            get: function(key){
                var data = store.get(key);
                if(!data) return null;
                //超过有效期，或js版本号发生变化，则移除数据返回空值
                if(new Date().getTime() - data.time > data.exp || data.ver !== _gl._version) {
                    store.remove(key);
                    return null;
                }
                return data.val;
            },
            remove:function(key){
                store.remove(key);
            }
        }
    }

    function getStrLength(a, b, c){
        b || (b = 1),
        c || (c = .5);
        var d = 0
            , e = 0
            , f = 0;
        return 1 == b && .5 == c ? (d = Math.abs(a.replace(/[\x00-\xff]*/g, "").length),
            e = Math.abs(Math.ceil(a.replace(/[^\x00-\xff]*/g, "").length / 2)),
            f = d + e + "") : f = 2 == b && 1 == c ? Math.abs(a.replace(/[^\x00-\xff]/g, "**").length) : 3 == b && 1 == c ? Math.abs(a.replace(/[^\x00-\xff]/g, "***").length) : a.length,
            f
    }

    //常规正则
    function regExp(){
        return {
            "username":"^[\\u4e00-\\u9fa5_a-zA-Z0-9-]{1,16}$",
            "password":"^([A-Z]|[a-z]|[0-9]|[`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]){6,20}$",
            "email":"^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$",
            "mobile":"^1[3|4|5|7|8]\\d{9}$"
        }
    }

    //倒计时方法
    var stopSetTimeOut = false;
    function countDownTimeFun(time,thisP,callback){
        thisP = thisP instanceof $ ? thisP : $(thisP);
        stopSetTimeOut = false;
        if(time){
            countTimeFun();
            function countTimeFun(){
                return setTimeout(function(){
                    time--;
                    if(time<=0){
                        if(callback && typeof(callback)=="function") callback();
                    }else{
                        thisP.html(time);
                        if(!stopSetTimeOut) countTimeFun();
                    }
                },1000);
            }
        }
    }
    function stopCountDownTimeFun(){
        stopSetTimeOut=true;
    }

    //通过邮箱后缀，返回邮件厂商
    function getEmailFactory(emailStr){
        var factory = emailStr.substring(emailStr.indexOf("@")+1) || "";
        if(factory=="qq.com"){
            return "https://mail.qq.com/";
        }else if(factory=="126.com"){
            return "http://mail.126.com/";
        }else if(factory=="163.com"){
            return "http://mail.163.com/";
        }else{
            return "";
        }
    }

    //
    function GUID(){
        this.date = new Date();

        /* 判断是否初始化过，如果初始化过以下代码，则以下代码将不再执行，实际中只执行一次 */
        if (typeof this.newGUID != 'function') {

            /* 生成GUID码 */
            GUID.prototype.newGUID = function() {
                this.date = new Date();
                var guidStr = '';
                sexadecimalDate = this.hexadecimal(this.getGUIDDate(), 16);
                sexadecimalTime = this.hexadecimal(this.getGUIDTime(), 16);
                for (var i = 0; i < 9; i++) {
                    guidStr += Math.floor(Math.random()*16).toString(16);
                }
                guidStr += sexadecimalDate;
                guidStr += sexadecimalTime;
                while(guidStr.length < 32) {
                    guidStr += Math.floor(Math.random()*16).toString(16);
                }
                return this.formatGUID(guidStr);
            }

            /*
             * 功能：获取当前日期的GUID格式，即8位数的日期：19700101
             * 返回值：返回GUID日期格式的字条串
             */
            GUID.prototype.getGUIDDate = function() {
                return this.date.getFullYear() + this.addZero(this.date.getMonth() + 1) + this.addZero(this.date.getDay());
            }

            /*
             * 功能：获取当前时间的GUID格式，即8位数的时间，包括毫秒，毫秒为2位数：12300933
             * 返回值：返回GUID日期格式的字条串
             */
            GUID.prototype.getGUIDTime = function() {
                return this.addZero(this.date.getHours()) + this.addZero(this.date.getMinutes()) + this.addZero(this.date.getSeconds()) + this.addZero( parseInt(this.date.getMilliseconds() / 10 ));
            }

            /*
             * 功能: 为一位数的正整数前面添加0，如果是可以转成非NaN数字的字符串也可以实现
             * 参数: 参数表示准备再前面添加0的数字或可以转换成数字的字符串
             * 返回值: 如果符合条件，返回添加0后的字条串类型，否则返回自身的字符串
             */
            GUID.prototype.addZero = function(num) {
                if (Number(num).toString() != 'NaN' && num >= 0 && num < 10) {
                    return '0' + Math.floor(num);
                } else {
                    return num.toString();
                }
            }

            /*
             * 功能：将y进制的数值，转换为x进制的数值
             * 参数：第1个参数表示欲转换的数值；第2个参数表示欲转换的进制；第3个参数可选，表示当前的进制数，如不写则为10
             * 返回值：返回转换后的字符串
             */
            GUID.prototype.hexadecimal = function(num, x, y) {
                if (y != undefined) {
                    return parseInt(num.toString(), y).toString(x);
                } else {
                    return parseInt(num.toString()).toString(x);
                }
            }

            /*
             * 功能：格式化32位的字符串为GUID模式的字符串
             * 参数：第1个参数表示32位的字符串
             * 返回值：标准GUID格式的字符串
             */
            GUID.prototype.formatGUID = function(guidStr) {
                var str1 = guidStr.slice(0, 8) + '-',
                    str2 = guidStr.slice(8, 12) + '-',
                    str3 = guidStr.slice(12, 16) + '-',
                    str4 = guidStr.slice(16, 20) + '-',
                    str5 = guidStr.slice(20);
                return str1 + str2 + str3 + str4 + str5;
            }
        }
    }

    return{
        loadStyles:loadStyles,
        loadScript:loadScript,
        loadScriptString:loadScriptString,
        getDocumentBaseData:getDocumentBaseData,
        getCurrentDate:getCurrentDate,
        getDifferDays:getDifferDays,
        isUndefined: function(a) {
            return "undefined" == typeof a ? !0 : !1;
        },
        getStrLength: getStrLength,
        urlencode: function(url) {
            return encodeURIComponent(url);
        },
        urldecode: function(url) {
            return decodeURIComponent(url);
        },
        betweenLength: function(ele, min, max, noZero) {
            var e = "string" == typeof ele ? ele : ele.val()
                , f = noZero ? getStrLength(e, 2, 1) : getStrLength(e, 1, 1);
            return f >= min && max >= f
        },
        betweenEquis: function(a, b) {
            var c = "string" == typeof a ? a : a.val()
                , d = "string" == typeof b ? b : b.val();
            return c === d
        },
        isNumber: function(a) {
            return !isNaN(a);
        },
        random: function(from, to) {
            return parseInt(Math.random() * (to - from + 1) + from);
        },
        timestamp: function() {
            return Date.parse(new Date) / 1e3;
        },
        timestamp_ms: function() {
            return Date.parse(new Date);
        },
        throttle:throttle,
        throttle_delay:throttle_delay,
        throttle_duration:throttle_duration,
        getRequest:getRequest,
        getBrowserType:getBrowserType,
        storeWithExpiration:storeWithExpiration,
        regExp:regExp,
        countDownTimeFun:countDownTimeFun,
        stopCountDownTimeFun:stopCountDownTimeFun,
        getEmailFactory:getEmailFactory,
        isPC:isPC,
        getGuid:function(){return new GUID().newGUID();}
    };
})(_store);


(function () {
    if (!Array.prototype.select) {
        /*
         * 将数组每一项进行指定转换,返回新的数组
         * @param string|function, 属性或过滤函数
         * @return Array
         */
        Array.prototype.select = function (arg) {
            var i = 0, len = this.length, result = [];
            if (len == 0) return result;
            while (i < len) {
                if (i in this && this[i] !== undefined) {
                    if (typeof arg == "string" && this[i].hasOwnProperty(arg)) {
                        result.push(this[i][arg]);
                    } else if (typeof arg == "function") {
                        result.push(arg.call(this, this[i], i, this));
                    }
                }
                i++;
            }
            return result;
        }
    }
    if (!Array.prototype.sum) {
        /*
         * 统计数组中符合条件的项的和
         * @param function, 过滤函数
         * @return number
         */
        Array.prototype.sum = function (f) {
            var i = 0, len = this.length, total = 0;
            if (len == 0) return total;
            while (i < len) {
                total += f.call(this, this[i], i, this);
                i++;
            }
            return total;
        }
    }
    if (!Array.prototype.count) {
        /*
         * 统计数组中符合条件的项的个数
         * @param function, 过滤函数
         * @return number
         */
        Array.prototype.count = function (f) {
            var i = 0, len = this.length, count = 0;
            if (len == 0) return count;
            while (i < len) {
                if (f.call(this, this[i], i, this)) {
                    count++;
                }
                i++;
            }
            return count;
        }
    }
    if (!Array.prototype.all) {
        /*
         * 判断数组中是否所有项都满足条件
         * @param function, 函数
         * @return boolean
         */
        Array.prototype.all = function (f) {
            var i = 0, len = this.length;
            if (len == 0) return true;
            while (i < len) {
                if (i in this && !f.call(this, this[i], i, this)) {
                    return false;
                }
                i++;
            }
            return true;
        }
    }

    if (!Array.prototype.any) {
        /*
         * 判断数组中是否存在满足条件的项
         * @param function, 函数
         * @return boolean
         */
        Array.prototype.any = function (f) {
            var i = 0, len = this.length;
            if (len == 0) return false;
            while (i < len) {
                if (i in this && f.call(this, this[i], i, this)) {
                    return true;
                }
                i++;
            }
            return false;
        };
    }
    if (!Array.prototype.first) {
        /*
         * 过滤数组中满足条件的第一项
         * @param function, 函数
         * @return 数组元素
         */
        Array.prototype.first = function (f) {
            var i = 0, len = this.length;
            if (len == 0) return null;
            while (i < len) {
                if (i in this && f.call(this, this[i], i, this)) {
                    return this[i];
                }
                i++;
            }
            return null;
        };
    }
    if (!Array.prototype.forEach) {
        /*
         * 对数组的每一项分别执行指定的函数
         * @param function, 函数
         */
        Array.prototype.forEach = function (f) {
            var i = 0, len = this.length;
            if (len == 0) return;
            while (i < len) {
                if (i in this) {
                    var item = this[i];
                    //返回false则跳出循环
                    if (f.call(this, item, i, this) === false) break;
                    this[i] = item;
                }
                i++;
            }
        };
    }
    if (!Array.prototype.where) {
        /*
         * 找出数组中符合条件的项
         * @param string|function, 属性或过滤函数
         * @return Array
         */
        Array.prototype.where = function (f) {
            var i = 0, len = this.length, result = [];
            if (len == 0) return result;
            while (i < len) {
                if (i in this && f.call(this, this[i], i, this)) {
                    result.push(this[i]);
                }
                i++;
            }
            return result;
        };
    }
    //for ie8
    if (!Array.prototype.indexOf) {
        /*
         * 数组的indexOf方法,IE8及以下版本浏览器没有内置indexOf方法
         * @param 数组元素
         * @param 查询的其实位置
         * @return number
         */
        Array.prototype.indexOf = function (elt /*, from*/) {
            var len = this.length >>> 0, from = Number(arguments[1]) || 0;
            from = (from < 0) ? Math.ceil(from) : Math.floor(from);
            if (from < 0) from += len;
            for (; from < len; from++) {
                if (from in this && this[from] === elt)
                    return from;
            }
            return -1;
        };
    }
    if (!Array.prototype.max) {
        /*
         * 查询数组中的过滤后值最大的项
         * @param function, 过滤函数
         * @return Array
         */
        Array.prototype.max = function (f) {
            var i = 1, len = this.length, tmp;
            if (len == 0) return null;
            tmp = this[0];
            var flag = f && typeof f == "function", left, right;
            while (i < len) {
                left = flag ? f.call(this, tmp, i - 1, this) : tmp;
                right = flag ? f.call(this, this[i], i, this) : this[i];
                if (i in this && left <= right) {
                    tmp = this[i];
                }
                i++;
            }
            return tmp;
        };
    }
    if (!Array.prototype.min) {
        /*
         * 查询数组中的过滤后值最小的项
         * @param function, 过滤函数
         * @return Array
         */
        Array.prototype.min = function (f) {
            var i = 1, len = this.length, tmp;
            if (len == 0) return null;
            tmp = this[0];
            var flag = f && typeof f == "function", left, right;
            while (i < len) {
                left = flag ? f.call(this, tmp, i - 1, this) : tmp;
                right = flag ? f.call(this, this[i], i, this) : this[i];
                if (i in this && left >= right) {
                    tmp = this[i];
                }
                i++;
            }
            return tmp;
        };
    }
    if (!Array.prototype.contains) {
        /*
         * 检测数组中是否包含给定元素
         * @param element | function, 查询元素或过滤函数
         * @return Array
         */
        Array.prototype.contains = function (arg) {
            if (typeof arg != "function") return this.indexOf(arg) >= 0;
            var i = 0, len = this.length;
            if (len == 0) return false;
            while (i < len) {
                if (i in this && arg.call(this, this[i], i, this)) {
                    return true;
                }
                i++;
            }
            return false;
        }
    }
    if (!Array.prototype.remove) {
        /*
         * 移除数组中符合条件的项
         * @param function, 过滤函数
         */
        Array.prototype.remove = function (f) {
            var len = this.length, i = len - 1, idxs = [];
            if (len == 0) return;
            while (i >= 0) {
                if (i in this && f.call(this, this[i], i, this)) {
                    idxs.push(i);
                }
                i--;
            }
            for (i = 0; i < idxs.length; i++) {
                this.splice(idxs[i], 1);
            }
        }
    }
    if (!Array.prototype.distinct) {
        /*
         * 去除数组中的重复项,返回不包含重复项的新数组
         * @param string | function, 对象属性名 或 过滤函数
         * @return Array
         */
        Array.prototype.distinct = function (arg) {
            var len = this.length, i = 0, result = [];
            if (len == 0) return result;
            while (i < len) {
                var cur = this[i];
                if (i in this && cur) {
                    if (typeof arg == "string" && cur.hasOwnProperty(arg) &&
                        !result.contains(function (r) { return r[arg] == cur[arg]; })) {
                        result.push(cur);
                    } else if (typeof arg == "object" && arg instanceof Array &&
                        !result.contains(function (r) {
                            return arg.all(function (a) { return cur.hasOwnProperty(a) && r[a] == cur[a]; });
                        })) {
                        result.push(cur);
                    }
                }
                i++;
            }
            return result;
        }
    }

    if (!Array.prototype.equal) {
        /*
         * 判断两个数组是否相同
         * @param Array, 与之比较的另一数组
         * @return Boolean
         */
        Array.prototype.equal = function (target) {
            if (!(target instanceof Array)) return false;
            var i = 0, len = this.length;
            if (len != target.length) return false;
            while (i < len) {
                if (this[i] != target[i]) return false;
                i++;
            }
            return true;
        }
    }

    if (!String.prototype.trim) {
        /*
         * 去掉字符串中的空白符号
         * @param function, 过滤函数
         * @return string
         */
        String.prototype.trim = function () {
            return this.replace(/^(\s*)(\S+.*\S+)(\s*)$/, "$2");
        }
    }
    if (!String.prototype.trimLeft) {
        /*
         * 去掉字符串开头的空白符号
         * @param function, 过滤函数
         * @return string
         */
        String.prototype.trimLeft = function () {
            return this.replace(/^(\s*)(\S+.*)$/, "$2");
        }
    }
    if (!String.prototype.trimRight) {
        /*
         * 去掉字符串结尾的空白符号
         * @param function, 过滤函数
         * @return string
         */
        String.prototype.trimRight = function () {
            return this.replace(/^(.*\S+)(\s*)$/, "$1");
        }
    }
    //firefox 内置contains方法,后重命名为includes方法,case sensitive
    String.prototype.contains = function (val, ignoreCase) {
        /*
         * 判断字符串是否包含指定内容
         * @param string, 给定的子字符串
         * @param boolean, 指示是否忽略大小写
         * @return boolean
         */
        if(!val) return true;
        return !ignoreCase ? this.indexOf(val) >= 0
            : this.toLowerCase().indexOf(val.toLowerCase()) >= 0;

    }
    if (!String.prototype.startWith) {
        /*
         * 判断字符串是否以指定内容开头
         * @param string, 给定的子字符串
         * @param boolean, 指示是否忽略大小写
         * @return boolean
         */
        String.prototype.startWith = function (val, ignoreCase) {
            return ignoreCase ? this.toLowerCase().indexOf(val.toLowerCase()) == 0 : this.indexOf(val) == 0;
        }
    }
    if (!String.prototype.format) {
        /*
         * 将字符串用给定的值进行格式化
         * 使用占位符({n}),n为0-9的数字
         * @param Array | strings, 格式化参数
         * @return string
         */
        String.prototype.format = function (/*arg1,arg2,arg3...*/) {
            if (arguments.length == 0) return this;
            var args = arguments[0];
            if(!(args instanceof Array)) args = arguments;
            var result = this.replace(/\{(\d)\}/g, function (placeholder, index) {
                return args[parseInt(index, 10)];
            });
            return result;
        }
    }
    //show a string of number in comma separate format
    //eg. "12345" -> "123,45"
    if (!String.prototype.toSeparate) {
        /*
         * 将只包含数字的字符串加入千分符(,)
         * @return string
         */
        String.prototype.toSeparate = function () {
            var sign = this.indexOf("-") == 0;
            var whole = (sign ? this.replace("-", "") : this).split("."), result = [];
            var arr = whole[0].split("").reverse(), decimal = whole[1];
            for (var i = 0; i < arr.length; i++) {
                result.push(arr[i]);
                if ((i + 1) % 3 == 0 && (i + 1 < arr.length)) result.push(",");
            }
            return (sign ? "-" : "") + result.reverse().join("") + (decimal ? "." + decimal : "");
        }
    }
    //show a number in comma separate format
    //eg. 12345 -> "123,45"
    if (!Number.prototype.toSeparate) {
        /*
         * 将数字以千分符的形式显示
         * @return string
         */
        Number.prototype.toSeparate = function () {
            return this.toString(10).toSeparate();
        }
    }

    if (!Date.prototype.addSeconds){
        Date.prototype.addSeconds = function(seconds){
            return new Date(this.getTime() + seconds * 1000);
        }
    }
    if (!Date.prototype.addMinutes){
        Date.prototype.addMinutes = function(minutes){
            return new Date(this.getTime() + minutes * 60 * 1000);
        }
    }
    if (!Date.prototype.addHours){
        Date.prototype.addHours = function(hours){
            return new Date(this.getTime() + hours * 60 * 60 * 1000);
        }
    }
    if (!Date.prototype.addDays){
        Date.prototype.addDays = function(days){
            return new Date(this.getTime() + days * 24 * 60 * 60 * 1000);
        }
    }
    if (!Date.prototype.addMonths){
        Date.prototype.addMonths = function(months){
            var m = this.getMonth();
            if(m+months>11){
                this.setMonth(m+months-12);
                this.setFullYear(this.getFullYear()+1);
            }else{
                this.setMonth(m+months);
            }
            return new Date(this);
        }
    }

    if (!Date.fromString){
        Date.fromString = function(date){
            if(!date) return new Date();
            date = date.replace(/\-/g, "\/").replace("T", " ").split(".")[0];
            return new Date(date);
        }
    }

    //YYYY-MM-DD hh:mm:ss
    if(!Date.prototype.format){
        Date.prototype.format = function(fmt) {
            var format = fmt || "";
            var obj = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日,
                "D+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            if (/([yY]+)/.test(format))
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in obj){
                if(new RegExp("(" + k + ")").test(format))
                    format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (obj[k]) : (("00" + obj[k]).substr(("" + obj[k]).length)));
            }
            return format;
        }
    }
})();


//简单提示弹窗
function layerMsg(obj,callback){
    if(!obj) obj={};
    var html='<div class="prompt_box bd-info">' +
        '<div class="icons bg-info">' +
        '<i class="icon-prompt-'+(obj.icon||"info")+'"></i>' +
        '</div>' +
        '<div class="plate-text text-center">' +
        '<p class="tip font26">'+(obj.content||"")+'</p>' +
        '</div>' +
        '</div>';
    layer.open({
        skin:'layer-member',
        title:false,
        closeBtn:false,
        content:html,
        btn:false,
        area:"450px",
        shift:1,
        success:function(layero,index){
            setTimeout(function(){layer.close(index);},(obj.time||1500));
        },
        end:function(){
            if(!callback && typeof(callback)=="function") callback();
        }
    });
}
var _gl = window._gl || {};
_gl.environment="local";
_gl.ajaxUrl={
    "local":{
        "settimeoutTime":800
    },
    "production":{
        "settimeoutTime":0
    }
};
var _server=(function($,_helper){
    var getJSON=function(obj){
        if(!obj) obj={};
        setTimeout(function(){
            if(false){
                $.ajax({
                    type:"GET",
                    url:obj.url,
                    data:obj.params,
                    dataType: 'json',
                    success:function(res){
                        if(res){
                            if(res.result==1){
                                if(obj.callback) obj.callback(res.data);
                            }else{
                                if(typeof(msg) == "object"){
                                    res.msg = JSON.stringify(res.msg);
                                }
                                $.toast(res.msg);
                            }
                        }else{
                            $.toast("返回数据异常");
                        }
                    },
                    error:function(data){
                        $.toast("网络异常，请稍后再尝试！");
                        if(obj.errorcallback && typeof (obj.errorcallback) == "function") obj.errorcallback();
                    },
                    complete:function(){
                        $.hidePreloader();
                        if(obj.completecallback && typeof (obj.completecallback) == "function") obj.completecallback();
                    }
                });
            }else{
                var url = obj.url.substring(obj.url.lastIndexOf("/")+1,obj.url.lastIndexOf("."));
                var res = JSON_Data[url];
                if(res){
                    if(res.result==1){
                        if(obj.callback) obj.callback(res.data);
                    }else{
                        if(typeof(msg) == "object"){
                            res.msg = JSON.stringify(res.msg);
                        }
                        $.toast(res.msg);
                    }
                }else{
                    $.toast("返回数据异常");
                }
                $.hidePreloader();
            }
        },_gl.ajaxUrl[_gl.environment].settimeoutTime);
    };
    var UserInfo_Service=function(){
        var USERID_KEYWORD = 'CurrentUserID';
        var USERINFO_KEYWORD = 'CurrentUserInfo';
        return {
            setUserId:function(userId){
                _helper.storeWithExpiration().set(USERID_KEYWORD,userId);
            },
            setUserInfo:function(userInfo){
                _helper.storeWithExpiration().set(USERINFO_KEYWORD,userInfo);
            },
            getUserInfo: function () {
                return _helper.storeWithExpiration().get(USERINFO_KEYWORD);
            },
            getUserId:function(){
                return _helper.storeWithExpiration().get(USERID_KEYWORD);
            },
            getUserInfoAsyn:function(userInfo,callback,callback1,callback2){
                if(!userInfo) userInfo={};
                getJSON({
                    "url":"/getUserInfo",
                    "params":userInfo,
                    "callback":function(user){
                        _helper.storeWithExpiration().set(USERINFO_KEYWORD,user);
                        _helper.storeWithExpiration().set(USERID_KEYWORD,user.userId||0);
                        if(callback && typeof (callback) == "function") callback(user);
                    },
                    "errorcallback":function(){if(callback1 && typeof (callback1) == "function") callback1();},
                    "completecallback":function(){if(callback2 && typeof (callback2) == "function") callback2();}
                });
            },
            removeUserInfo:function(){
                _helper.storeWithExpiration().remove(USERINFO_KEYWORD);
                _helper.storeWithExpiration().remove(USERID_KEYWORD);
            },
            getLoginState:function(){
                getJSON({
                    "url":"/getUserInfo",
                    "params":{"mod":"member","inc":"state"},
                    "callback":function(data){
                        if(data.hasLogin){
                            _helper.storeWithExpiration().set(USERINFO_KEYWORD,data.userInfo);
                            _helper.storeWithExpiration().set(USERID_KEYWORD,data.userInfo.userId||0);
                        }else{
                            _helper.storeWithExpiration().remove(USERINFO_KEYWORD);
                            _helper.storeWithExpiration().remove(USERID_KEYWORD);
                        }
                    }
                });
            }
        }
    };
    return {
        UserInfo_Service:UserInfo_Service,
        getJSON:getJSON
    }
})(Zepto,_helper);


var _media = (function($,_helper){
    var VIDEO_DEFAULT={
        //播放控制栏
        controls:true,

        //是否自动播放 是一个布尔属性
        //autoplay或者 autoplay=”autoplay”
        autoplay:false,

        //指定视频是否循环播放 是一个布尔属性
        loop:"loop",

        //预加载
        //None：不进行预加载
        //Metadata：部分预加载
        //Auto：全部预加载
        preload:"None",

        //默认图片
        poster:"'+_gl._host_res+'/images/product/default_video.png",

        //视频的宽高
        width:"100%",
        height:"180"
    };
    //创建一个视频模块
    function createVideo(options){
        if(!options) options={};
        var html='';
        if(!options.sourceList || options.sourceList.length<=0){
            if(!!options.shell) {
                html = '<div class="video-item">';
                html += '</div>';
            }
        }else{
            if(!!options.shell){
                html='<div class="video-item">';
            }
            html+= '<video id="'+_helper.getGuid()+'"';
            html+=' width="'+(options.width||VIDEO_DEFAULT.width)+'"';
            html+=' height="'+(options.height||VIDEO_DEFAULT.height)+'"';
            html+=' poster="'+(options.poster||VIDEO_DEFAULT.poster)+'"';
            html+=' preload="'+(options.preload||VIDEO_DEFAULT.preload)+'"';
            if(options.autoplay||VIDEO_DEFAULT.autoplay) html+=' autoplay';
            if(options.loop||VIDEO_DEFAULT.loop) html+=' loop';
            if(options.controls||VIDEO_DEFAULT.controls) html+=' controls';
            html+=' x5-video-player-type="h5" x5-video-player-fullscreen="true" webkit-playsinline>';
            for(var a= 0,a1=options.sourceList.length;a<a1;a++){
                html+='<source src='+options.sourceList[a].src+' type="'+(options.sourceList[a].type||"video/mp4")+'" />';
            }
            html+='</video>';
            if(!!options.shell){
                html+='</div>';
            }
        }
        html = $(html);
        var $video=html;
        if(!!options.shell){
            $video = html.find("video");
        }
        $video.bind("click",function(e){
            e.stopPropagation();
            toggle($(this).attr("id"));
        });
        return html;
    }
    //设置视频的第一帧为背景图片
    function captureImage(id){
        var video = document.getElementById(id);
        var scale=1;
        video.addEventListener('loadeddata',function(){
            console.log("6666");
            var canvas = document.createElement("canvas");
            canvas.width = video.videoWidth * scale;
            canvas.height = video.videoHeight * scale;
            canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
            $("#"+id).attr("poster",canvas.toDataURL("image/png"));
        });
    }

    var AUDIO_DEFAULT={
        //播放控制栏
        controls:true,

        //是否自动播放 是一个布尔属性
        //autoplay或者 autoplay=”autoplay”
        autoplay:false,

        //指定视频是否循环播放 是一个布尔属性
        loop:"loop",

        //预加载
        //None：不进行预加载
        //Metadata：部分预加载
        //Auto：全部预加载
        preload:"None",

        //视频的宽高
        width:"100%",
        height:"auto"
    };
    //创建一个音频模块
    function createAudio(options){
        if(!options) options={};
        var html='';
        if(!options.sourceList || options.sourceList.length<=0){
            if(!!options.shell) {
                html='<div class="audio-item">';
                html+='</div>';
            }
        }else{
            if(!!options.shell){
                html='<div class="audio-item">';
            }
            html+= '<audio id="'+_helper.getGuid()+'"';
            html+=' width="'+(options.width||AUDIO_DEFAULT.width)+'"';
            html+=' height="'+(options.height||AUDIO_DEFAULT.height)+'"';
            html+=' preload="'+(options.preload||AUDIO_DEFAULT.preload)+'"';
            if(options.autoplay||AUDIO_DEFAULT.autoplay) html+=' autoplay';
            if(options.loop||AUDIO_DEFAULT.loop) html+=' loop';
            if(options.controls||AUDIO_DEFAULT.controls) html+=' controls';
            html+=' >';
            for(var a= 0,a1=options.sourceList.length;a<a1;a++){
                html+='<source src='+options.sourceList[a].src+' type="'+(options.sourceList[a].type||"audio/mpeg")+'" />';
            }
            html+='</audio>';
            if(!!options.shell){
                html+='</div>';
            }
        }
        return html;
    }

    //播放或者暂停
    function toggle(id){
        var Media = document.getElementById(id);
        if(Media){
            if(!Media.paused){
                Media.pause();
            }else{
                Media.play();
            }
        }
    }

    //开始播放
    function play(id){
        var Media = document.getElementById(id);
        if(Media && Media.played){
            Media.play();
        }
    }
    //暂停播放
    function pause(id){
        var Media = document.getElementById(id);
        if(Media && !Media.paused){
            Media.pause();
        }
    }
    //重新播放
    function replay(id){
        var Media = document.getElementById(id);
        if(Media){
            Media.currentTime=0;
            Media.play();
        }
    }

    return {
        createVideo:createVideo,
        createAudio:createAudio,
        play:play,
        pause:pause,
        replay:replay,
        captureImage:captureImage
    };
})(Zepto,_helper);


var JSON_Data = {
    "readingChapter":{
        "result":1,
        "data":{
            "name":"Introduction",
            "seq":"第一章",
            "media_type":"audio",
            "content":"内容"
        },
        "msg":""
    },
    "g1_1":{
        "result":1,
        "data":{
            "name":"Introduction",
            "seq":"第一章",
            "media_type":"audio",
            "content":'<p>《晚安，大猩猩》是一本经典绘本。绘本色彩鲜明，动物表情有趣。很贴切孩子的认知发展。这本书图画感强，但是句子却很少，而且简单。在教育工作者看来是一本很好的绘本，因为约束性小，可拓展出的内容多，可激发孩子想象的空间大。但是很多妈妈却觉得很难读，因为自身语言的限制、思维的限制。今天我们就来一起读一读这本字少，玩法却很多的绘本书。</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-1.png" width="100%"></div>'
        },
        "msg":""
    },
    "g1_2":{
        "result":1,
        "data":{
            "name":"Key Words",
            "seq":"第二章",
            "media_type":"video",
            "media_src":"http://www.runoob.com/try/demo_source/movie.mp4",
            "content":'<p class="key-words"><span class="L">Gorilla:</span><span class="R">大猩猩</span></p>' +
            '<p class="key-words"><span class="L">Elephant:</span><span class="R">大象</span></p>' +
            '<p class="key-words"><span class="L">Lion:</span><span class="R">狮子</span></p>' +
            '<p class="key-words"><span class="L">Giraffe:</span><span class="R">长颈鹿</span></p>' +
            '<p class="key-words"><span class="L">Hyena:</span><span class="R">土狼</span></p>' +
            '<p class="key-words"><span class="L">Armadillo:</span><span class="R">穿山甲</span></p>' +
            '<p class="key-words"><span class="L">Zoo keeper:</span><span class="R">动物园管理员</span></p>' +
            '<p class="key-words"><span class="L">Wife:</span><span class="R">妻子</span></p>' +
            '<p class="key-words"><span class="L">Cage:</span><span class="R">笼子</span></p>' +
            '<p class="key-words"><span class="L">Key:</span><span class="R">钥匙</span></p>' +
            '<p class="key-words"><span class="L">Amaranth:</span><span class="R">紫红色</span></p>' +
            '<p class="key-words"><span class="L">Flashlight:</span><span class="R">手电筒</span></p>' +
            '<p class="key-words"><span class="L">Steal:</span><span class="R">偷</span></p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-2.png" width="100%"></div>'
        },
        "msg":""
    },
    "g1_3":{
        "result":1,
        "data":{
            "name":"Key Sentences",
            "seq":"第三章",
            "media_type":"video",
            "media_src":"http://www.runoob.com/try/demo_source/movie.mp4",
            "content":'<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>What is this animal?</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>这是什么动物?</p>' +
            '<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>What color of its cage ?</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>它的笼子是什么颜色的?</p>' +
            '<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>What’s color of the key can open this cage?</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>打开这个笼子的钥匙应该是什么颜色的?</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-3.png" width="100%"></div>'
        },
        "msg":""
    },
    "g1_4":{
        "result":1,
        "data":{
            "name":"Supplement",
            "seq":"第四章",
            "media_type":"video",
            "media_src":"http://www.runoob.com/try/demo_source/movie.mp4",
            "content":'<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>What time is it ? Day time or night time?</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>现在是什么时间？白天还是晚上？</p>' +
            '<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>They line up and follow the zoo keeper.</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>他们排队，跟着动物园管理员。</p>' +
            '<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>Who are saying good night ?</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>谁在说晚安？</p>' +
            '<p class="key-sentences p-en"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>zoo keeper’s wife takes the animals back to the zoo.</p>' +
            '<p class="key-sentences"><i class="fa fa-paper-plane-o" aria-hidden="true"></i>动物园管理员的妻子将动物们都带回动物园了。</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-4.png" width="100%"></div>'
        },
        "msg":""
    },
    "g1_5":{
        "result":1,
        "data":{
            "name":"Parents-Child Activities",
            "seq":"第五章",
            "media_type":"video",
            "media_src":"http://www.runoob.com/try/demo_source/movie.mp4",
            "content":'<p class="pc-subtitle"><i class="fa fa-diamond" aria-hidden="true"></i>&nbsp;&nbsp;Matching</p>' +
            '<p class="pc-content">互动过程中的对话：</p>' +
            '<p class="pc-content p-en">Parents:  what’s color of this cage ?</p>' +
            '<p class="pc-content">这个笼子是什么颜色的？</p>' +
            '<p class="pc-content p-en">Child:  this is ..</p>' +
            '<p class="pc-content">这是..</p>' +
            '<p class="pc-content p-en">Parents: what’s color of the key can open this cage?</p>' +
            '<p class="pc-content">什么颜色的钥匙可以打开笼子？</p>' +
            '<p class="pc-content p-en">Child:  ..key can open ..cage </p>' +
            '<p class="pc-content">ps:还可以配对一下这些动物的眼睛~</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-5.png" width="100%"></div>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-6.png" width="100%"></div>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-7.png" width="100%"></div><br>' +
            '<p class="pc-subtitle"><i class="fa fa-diamond" aria-hidden="true"></i>&nbsp;&nbsp;Sorting</p>' +
            '<p class="pc-content">在这个书中，出现的动物可以进行大、小分类。年纪大一些的孩子，还可以按照动物居住生活区域和习性分类，比如是丛林动物，还是平原？</p>' +
            '<p class="pc-content p-en">Parents:  which animals are big ?</p>' +
            '<p class="pc-content">哪些动物是大的？</p>' +
            '<p class="pc-content p-en">Parents:  which animals are small?</p>' +
            '<p class="pc-content">哪些动物是小的？</p>' +
            '<p class="pc-content p-en">Child: gorilla is big , lion is big , mouse is small, armadillo is small</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-8.png" width="100%"></div><br>' +
            '<p class="pc-subtitle"><i class="fa fa-diamond" aria-hidden="true"></i>&nbsp;&nbsp;Imitation</p>' +
            '<p class="pc-content">可以利用家里积木、玩偶模拟这本书的场景。比如打一个绿色的笼子，然后找一扇绿色的门。另外也可以和孩子来做角色扮演。有一个zoo keeper,一个gorilla,其他都可以用别的玩偶来替代。书本文字越少，约束越少。可发展的语言越多。</p>' +
            '<div class="product-img"><img src="'+_gl._host_res+'/images/product/goodnight/goodnight-9.png" width="100%"></div>'
        },
        "msg":""
    },
    "readingDetail":{
        "result":1,
        "data":{
            "id":"g1",
            "title":"Good night , gorilla",
            "time":"2016年11月11日",
            "media_type":"audio",
            "cover_img":"'+_gl._host_res+'/images/product/goodnight/goodnight-0.png",
            "chapters":[
                {
                    "id":"g1_1",
                    "name":"Introduction",
                    "seq":"第一章",
                    "content":"内容"
                },
                {
                    "id":"g1_2",
                    "name":"Key Words",
                    "seq":"第二章",
                    "content":"内容"
                },
                {
                    "id":"g1_3",
                    "name":"Key Sentences",
                    "seq":"第三章",
                    "content":"内容"
                },
                {
                    "id":"g1_4",
                    "name":"Supplement",
                    "seq":"第四章",
                    "content":"内容"
                },
                {
                    "id":"g1_5",
                    "name":"Parents-Child Activities",
                    "seq":"第五章",
                    "content":"内容"
                },
                {
                    "id":"g1_6",
                    "name":"带读视频",
                    "seq":"第六章",
                    "content":"内容"
                },
                {
                    "id":"g1_7",
                    "name":"拓展视频",
                    "seq":"第七章",
                    "content":"内容"
                },
                {
                    "id":"g1_8",
                    "name":"拓展材料",
                    "seq":"第八章",
                    "content":"内容"
                }
            ]
        },
        "msg":""
    },
    "readingList":{
        "result":1,
        "data":[
            {
                "id":"g1",
                "title":"Good night , gorilla",
                "subtitle":"《1晚安，大猩猩》是一本经典绘本。绘本色彩鲜明，动物表情有趣。很贴切孩子的认知发展。这本书图画感强，但是句子却很少，而且简单。在教育工作者看来是一本很好的绘本，因为约束性小，可拓展出的内容多，可激发孩子想象的空间大。但是很多妈妈却觉得很难读，因为自身语言的限制、思维的限制。今天我们就来一起读一读这本字少，玩法却很多的绘本书。",
                "time":"2016年10月26日 星期五",
                "cover":"'+_gl._host_res+'/images/product/goodnight/goodnight-1.png",
                "fabulous_count":9959,
                "comment_count":268
            },
            {
                "id":"g2",
                "title":"The hungry caterpillar",
                "subtitle":"明万历四十四年，后金天命元年，清太祖努尔哈赤建国称汗，国号大金，史称“后金”。1636年（明崇祯九年，清崇德元年），清太宗皇太极称帝，改国号为“大清”。1644年（明崇祯十七年、清顺治元年），李自成的大顺军攻占北京，明朝灭亡；驻守山海关的明将吴三桂降清，清摄政王多尔衮指挥清军入关，打败大顺农民军；同年清顺治帝迁都北京，从此清朝取代明朝成为全国的统治者。入关后20年时间里，清朝先后灭亡大顺、大西和南明等政权，基本统一全国。",
                "time":"2016年11月01日 星期五",
                "cover":"'+_gl._host_res+'/images/product/goodnight/goodnight-2.png",
                "fabulous_count":999,
                "comment_count":28
            },
            {
                "id":"g3",
                "title":"Rosie’ s walk",
                "subtitle":"《黄帝内经》是一本综合性的医书，在黄老道家理论上建立了中医学上的“阴阳五行学说”、“脉象学说”、“藏象学说”、“经络学说”、“病因学说”“病机学说”、“病症”、“诊法”、“论治”及“养生学”、“运气学”等学说，从整体观上来论述医学，呈现了自然、生物、心理、社会“整体医学模式”。 其基本素材来源于中国古人对生命现象的长期观察、大量的临床实践以及简单的解剖学知识。它奠定了人体生理、病理、诊断以及治疗的认识基础，是中国影响极大的一部医学著作，被称为医之始祖。",
                "time":"2016年10月01日 星期二",
                "cover":"'+_gl._host_res+'/images/product/goodnight/goodnight-3.png",
                "fabulous_count":3999,
                "comment_count":228
            },
            {
                "id":"g4",
                "title":"Old MacDonald had a farm",
                "subtitle":"全书收录植物药有881种，附录61种，共942种，再加上具名未用植物153种，共计1095种，占全部药物总数的58%。李时珍把植物分为草部[2-3]  、谷部[4]  、菜部[5]  、果部、本部五部，又把草部分为山草、芳草、溼草、毒草、蔓草、水草、石草、苔草、杂草等九类，是我国医药宝库中的一份珍贵遗产。",
                "time":"2016年10月01日 星期二",
                "cover":"'+_gl._host_res+'/images/product/goodnight/goodnight-1.png",
                "fabulous_count":3999,
                "comment_count":228
            }
        ],
        "msg":""
    },
    "productList":{
        "result":1,
        "data":[
            {
                "id":"1",
                "title":"本周直播",
                "subtitle":"夜黑风高，伸手不见五指，突然大风起...",
                "time":"2016年12月01日 星期一",
                "poster":"'+_gl._host_res+'/images/product/default_video.png",
                "fabulous_count":9959,
                "comment_count":268
            },
            {
                "id":"2",
                "title":"上期回顾",
                "subtitle":"尹教授家里又增添了一个可爱的小妹妹，三岁的俊熙和父亲一起去育婴室看妹妹恩熙，在护士不注意时，淘气的俊熙调换了恩熙与同一天出生的邻近小孩儿的牌子。就这样阴差阳错地两家的孩子被调了包。",
                "time":"2016年11月01日 星期五",
                "poster":"'+_gl._host_res+'/images/product/default_video.png",
                "fabulous_count":999,
                "comment_count":28
            },
            {
                "id":"3",
                "title":"下期介绍",
                "subtitle":"武当山，道教圣地，位于湖北省十堰市境内。武当山又名太和山、谢罗山、参上山、仙室山，古有“太岳”、“玄岳”、“大岳”之称。",
                "time":"2016年10月01日 星期二",
                "poster":"'+_gl._host_res+'/images/product/default_video.png",
                "fabulous_count":3999,
                "comment_count":228
            }
        ],
        "msg":""
    }
}
;(function($,_helper,_server){
    $(function(){
        //隐藏加载动画
        $(".WaitingIco").hide();

        //页面头部添加注册商标
        //addTextTop();
        //在页面底部添加注册商标
        var url = location.href;
        if(!(url.indexOf("succ")>-1 || url.indexOf("fail")>-1)){
            //addTextBottom();
        }




    });
    //页面头部添加注册商标
    function addTextTop(){
        var html = '<header class="bar bar-nav friday-header">\
                    <div>\
                    <img src="../../wx/images/logo/Fridaylogo.png">\
                        <span>FRIDAY 研习社</span>\
                    </div>\
                    </header>';
        $(".PcContainer>.page>.content").prepend(html);
    }

    //页面底部添加注册商标
    function addTextBottom(){
        var html = '<div class="logo-bottom"><p>快乐 亲子 全学科</p></div>';
        $(".PcContainer>.page>.content").append(html);
    }


})(Zepto,_helper,_server);




var requestAnimationFrameFlag =true;
//画logo
function createLogo(){
    requestAnimationFrameFlag = false;
    setTimeout(function(){
        var $logcanvas,$width,$height;
        //样式参数
        var $borderColor = "#fff";
        var $borderWidth = 2;
        var $backGroundColor = "#1f3d3f";
        var $testbackGroundColor = "#fff";
        var $letterCount = 240;
        var flagNum = 0;
        //字母数组
        var letterList =[];
        var letterStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var points=[
            {x:0.2,y:0.1},
            {x:0.8,y:0.1},
            {x:0.8,y:0.24},
            {x:0.32,y:0.24},
            {x:0.32,y:0.44},
            {x:0.56,y:0.44},
            {x:0.56,y:0.54},
            {x:0.32,y:0.54},
            {x:0.32,y:0.9},
            {x:0.2,y:0.9}
        ];

        var $canvas = document.createElement("canvas");
        if(!$canvas){
            $logcanvas.html('<div class="logo-part-1"></div><div class="logo-part-2"></div><div class="logo-part-3"></div><div class="logo-part-4"></div><div class="logo-part-5"></div><div class="logo-part-6"></div><div class="logo-part-7"></div><div class="logo-part-8"></div>');
            return false;
        }
        var $context = $canvas.getContext('2d');

        $logcanvas = $(".log-canvas");
        if($logcanvas.length<=0) return false
        $width = $logcanvas.width();
        $height = $width;
        $logcanvas.height($height);
        $canvas.width=$width;
        $canvas.height=$width;
        $logcanvas[0].appendChild($canvas);

        init();
        $(".log-card").css("visibility","visible");
        requestAnimationFrameFlag=true;
        (function drawFrame(){
            if(requestAnimationFrameFlag && flagNum<10000){
                window.requestAnimationFrame(drawFrame, $canvas);
            }else{
                window.cancelAnimationFrame(drawFrame, $canvas);
            }
            $context.clearRect(0, 0, $canvas.width, $canvas.height);
            drawLetters($context);
        }());

        function init(){
            createLetterList($letterCount);
            drawLetters($context);
        }

        $(".native-scroll").scroll(_helper.throttle_duration(function(){
            $logcanvas = $(".log-canvas");
            if($logcanvas.length<=0) return false
            if($logcanvas.width() != $width){
                $width = $logcanvas.width();
                $height = $width;
                $logcanvas.height($height);
                $canvas.width=$width;
                $canvas.height=$width;
                init();
            }
        },400,800));

        //获取字母的X Y 坐标
        function getPosition(){
            var x= _helper.random($width*0.2,$width*0.8);
            var y=0;
            if(x>0.56*$width){
                y= _helper.random($height*0.1,$height*0.22);
            }else if(x>0.32*$width && x<0.56*$width){
                y= _helper.random($height*0.1,$height*0.22);
                if(_helper.random(0,1)>0.5){
                    y= _helper.random($height*0.44,$height*0.54);
                }
            }else{
                y= _helper.random($height*0.1,$height*0.9);
            }
            return {x:x,y:y};
        }

        //随机创建字母数组，以及其随机属性
        function createLetterList(num){
            letterList=[];
            var p ={};
            for(var a=0;a<num;a++){
                p = getPosition();
                letterList.push({
                    "content":(letterStr.substr(_helper.random(0,52),1))||"A",
                    "x": p.x,
                    "y": p.y,
                    "dy":getDy(),
                    "color":"rgb("+getInt()+","+getInt()+","+getInt()+")",
                    "font":"bold "+(Math.floor(Math.random()*5+10))*2+"px 宋体"
                });
            }
        }

        //随机生成0-255之间的整数
        function getInt(){
            return Math.floor(Math.random()*255);
        }

        //随机产生下降速度
        function getDy(){
            return Math.random()*5+2;
        }

        //绘制文本
        function drawText(c,obj){
            if(!obj) return false;
            c.save();
            c.beginPath();
            c.font = obj.font;
            c.fillStyle = obj.color;
            c.fillText(obj.content,obj.x,obj.y);
            c.closePath();
        }

        //绘制背景
        function drawBackground(c){
            c.save();
            c.fillStyle = $backGroundColor;
            c.fillRect(0,0,$width,$height);
        }

        //绘制线条
        function drawLine(c){
            c.save();
            c.strokeStyle=$borderColor;
            c.lineWidth=$borderWidth;
            c.beginPath();
            c.moveTo($width*points[0].x,$height*points[0].y);
            for(var a= 1,a1=points.length;a<a1;a++){
                c.lineTo($width*points[a].x,$height*points[a].y);
            }
            c.closePath();
            c.stroke();
        }

        //绘制字母
        function drawLetters(c){
            flagNum++;
            drawBackground($context);
            for(var a= 0,a1=letterList.length;a<a1;a++){
                drawText(c,letterList[a]);
                letterList[a].y+=letterList[a].dy;
                if(letterList[a].y>$height){
                    letterList[a].x= getPosition().x;
                    letterList[a].y = 0;
                    letterList[a].dy = getDy();
                }
            }
            drawFrameBackGround($context);
            drawLine($context);
        }

        //重绘周边背景
        function drawFrameBackGround(c){
            c.save();
            c.fillStyle=$backGroundColor;
            c.beginPath();
            c.moveTo($width*0.8,$height*0);
            c.lineTo($width*1.0,$height*0);
            c.lineTo($width*1.0,$height*1.0);
            c.lineTo($width*0.32,$height*1.0);
            c.lineTo($width*points[7].x,$height*points[7].y);
            c.lineTo($width*points[6].x,$height*points[6].y);
            c.lineTo($width*points[5].x,$height*points[5].y);
            c.lineTo($width*points[4].x,$height*points[4].y);
            c.lineTo($width*points[3].x,$height*points[3].y);
            c.lineTo($width*points[2].x,$height*points[2].y);
            c.lineTo($width*points[1].x,$height*points[1].y);
            c.closePath();
            c.fill();

            c.save();
            c.beginPath();
            c.moveTo($width*0.8,$height*0);
            c.lineTo($width*0,$height*0);
            c.lineTo($width*0,$height*1.0);
            c.lineTo($width*0.2,$height*1.0);
            c.lineTo($width*points[0].x,$height*points[0].y);
            c.lineTo($width*points[1].x,$height*points[1].y);
            c.closePath();
            c.fill();

            c.save();
            c.beginPath();
            c.moveTo($width*points[9].x,$height*points[9].y);
            c.lineTo($width*points[8].x,$height*points[8].y);
            c.lineTo($width*0.32,$height*1.0);
            c.lineTo($width*0.2,$height*1.0);
            c.closePath();
            c.fill();
        }
    },50);
}

